package com.bee.shepherd.service.security;

import com.google.common.base.Preconditions;
import com.qunar.finance.nbdata.security.core.api.bean.NbKeyType;
import com.qunar.finance.nbdata.security.core.api.service.NbInfoEncryptClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * NB 加密服务
 */
//@Service
public class EncryptDataServiceImpl implements IEncryptDataService {

//    @Resource
    private NbInfoEncryptClient nbInfoEncryptClient;

    public String encryptPhone(String input) {
        return encrypt(input, NbKeyType.phone);
    }

    public String encryptMail(String input) {
        return encrypt(input, NbKeyType.mail);
    }

    public String encryptBankNo(String input) {
        return encrypt(input, NbKeyType.bankNo);
    }

    public String encryptPersonalId(String input) {
        return encrypt(input, NbKeyType.personal_id);
    }

    public String encryptPassport(String input) {
        return encrypt(input, NbKeyType.passport);
    }

    private String encrypt(String input,NbKeyType nbkeyType) {
        Preconditions.checkArgument(StringUtils.isNotBlank(input));
        return nbInfoEncryptClient.encrypt(nbkeyType, input);
    }
}
